import request from "@/api";
import { BaseRet, PageQuery, PageRet } from "../response";

export default class FormulaDataApi {
  /**
   * 查询
   * @returns
   */
  static async query(data: FormulaDataQuery): Promise<PageRet<FormulaDataModel>> {
    return await request({
      url: "/formulaData/query",
      method: "post",
      data: data,
    });
  }

  /**
   * 新增
   * @returns
   */
  static async create(data: FormulaDataEdit): Promise<BaseRet> {
    return await request({
      url: `/formulaData/create`,
      method: "post",
      data: data,
    });
  }

  /**
   * 修改
   * @returns
   */
  static async update(data: FormulaDataEdit): Promise<BaseRet> {
    return await request({
      url: `/formulaData/update`,
      method: "put",
      data: data,
    });
  }

  /**
   * 删除
   * @returns
   */
  static async delete(id: string): Promise<BaseRet> {
    return await request({
      url: `/formulaData/delete/${id}`,
      method: "delete",
    });
  }
}

export interface FormulaDataModel {
  id?: string;
  mainId?: string;
  formulaKey?: string;
  formulaName?: string;
  formulaValue?: string;
  variableIdArray?: string[];
  formulaKeyArray?: string[];
  formulaNameArray?: string[];
  entityType?: string;
  variablePrimaryKeys?: string;
}

export interface FormulaDataQuery extends PageQuery {
  searchString?: string;
}

export interface FormulaDataEdit {
  id?: string;
  mainId?: string;
  formulaKey?: string;
  formulaName?: string;
  formulaValue?: string;
  variableIdArray?: string[];
  formulaKeyArray?: string[];
  formulaNameArray?: string[];
  entityType?: string;
  variablePrimaryKeys?: string;
}
